package com.kaiwukj.android.ufamily.mvp.ui.widget.home;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.kaiwukj.android.mcas.http.imageloader.glide.GlideArms;
import com.kaiwukj.android.ufamily.R;
import com.kaiwukj.android.ufamily.mvp.http.entity.helper.LoginBannerBean;
import com.zhpan.bannerview.holder.ViewHolder;

public class LoginBannerHolder implements ViewHolder<LoginBannerBean> {

    private ImageView ivImage;
    private TextView tvTitle;
    private TextView tvDesc;

    @Override
    public View createView(ViewGroup viewGroup, Context context, int position) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_banner_login, viewGroup, false);
        ivImage = view.findViewById(R.id.iv_image);
        tvTitle = view.findViewById(R.id.tv_title);
        tvDesc = view.findViewById(R.id.tv_desc);
        return view;
    }

    @Override
    public void onBind(Context context, LoginBannerBean data, int position, int size) {
        GlideArms.with(context).load(data.getImgId())
                .skipMemoryCache(true)
                .centerCrop()
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                //.transform(cornerTransform)
                .into(ivImage);
        tvTitle.setText(data.getTitle());
        tvDesc.setText(data.getDesc());
    }
}
